package _99BeiWangLu;

/**
 * @Test: 备忘录模式测试类
 * @author: ZBoHang
 * @time: 2021/9/17 14:59
 */
class Test {
    public static void main(String[] args) {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();

        originator.setState("#1");
        originator.setState("#2");
        careTaker.add(originator.saveStateToMemento());

        originator.setState("#3");
        careTaker.add(originator.saveStateToMemento());

        System.out.println("@@@@@" + originator.getState());
        originator.getStateFromMemento(careTaker.get(0));
        System.out.println("@@@@@" + originator.getState());
        originator.getStateFromMemento(careTaker.get(1));
        System.out.println("@@@@@" + originator.getState());

    }
}
